package com.yaowk.email.model.page;

import com.jfinal.plugin.activerecord.Record;
import com.yaowk.common.model.Page;

import java.util.Map;
import java.util.TreeMap;

/**
 * @authc yaowk
 * 2017/5/11
 */
public class SearchPage extends Page {

    private String consigneeKeyword;
    private String titleKeyword;
    private Integer type;
    private Integer userId;

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getConsigneeKeyword() {
        return consigneeKeyword;
    }

    public void setConsigneeKeyword(String consigneeKeyword) {
        this.consigneeKeyword = consigneeKeyword;
    }

    public String getTitleKeyword() {
        return titleKeyword;
    }

    public void setTitleKeyword(String titleKeyword) {
        this.titleKeyword = titleKeyword;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @Override
    public Record toRecord() {
        Map<String, Object> map = new TreeMap<>();
        map.put("userId", userId);
        map.put("consigneeKeyword", consigneeKeyword);
        map.put("titleKeyword", titleKeyword);
        if (type <= 3) {
            map.put("type", type);
        }
        Record record = new Record().setColumns(map);
        return record.removeNullValueColumns();
    }
}
